<template>
  <el-dialog title="收货地址" :visible.sync="isOpen">
    <el-form :model="form" :style="{textAlign:'center'}">
      <el-form-item label="商品名称" label-width="200px">
        <el-input v-model="form.goods_name" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="价格" label-width="200px">
        <el-input v-model="form.goods_price" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="数量" label-width="200px">
        <el-input v-model="form.goods_number" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="重量" label-width="200px">
        <el-input v-model="form.goods_weight" autocomplete="off"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="isOpen = false">取 消</el-button>
      <el-button type="primary" @click="isOpen=false;submit()">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script lang="ts">
import { Component, Vue, Watch } from 'vue-property-decorator'
import { modifyGoods } from '@/api/goods'
import { good } from '@/store/goods/interface'

@Component
export default class ModifyGoods extends Vue {
  async submit () {
    this.form.goods_cat = '12'
    const { meta: { status, msg }, data } = await modifyGoods(this.form as any)
    this.open(msg, status === 200 ? 'success' : 'error')
    console.log(msg, status)
    if (status === 400) this.isOpen = false
    this.$emit('update')
  }

  public form = {
    goods_id: 0,
    goods_name: '',
    goods_price: 0,
    goods_number: 0,
    goods_cat: '',
    goods_weight: 0
  }

  open (
    smg = '登陆成功',
    type: 'success' | 'warning' | 'info' | 'error' = 'success'
  ) {
    this.$message({
      message: smg,
      type
    })
  }

  public isOpen = false
}
</script>

<style scoped>

</style>
